
//文档加载事件
// banner轮播
lunbo('#slider','420','1000','420');

// 电子书轮播
lunbo('#books1_slider','220','330','220','20','10','4','0');
lunbo('#books2_slider','220','330','200','12','10','4','0');
lunbo('#books3_slider','220','330','200','12','10','4','0');

// 电子书选项卡
cards('#ebook .left>.title>.card>a','#ebook .left>.con','ah','con_cur');
// 电子书右侧列表
list('#ebook>.right>ul>li','p','.con','hide','show');

// 服装lunbo
lunbo('#cloths1_slider','340','432','340','12','10','4','0');
lunbo('#cloths2_slider','340','432','340','12','10','4','0');
lunbo('#cloths3_slider','340','432','340','12','10','4','0');


// 服装选项卡
cards('#cloth>.title>.card>a','#cloth>.cloth_con','ah','cloth_cur');

// 户外运动轮播
lunbo('#sports1_slider','340','432','340','12','10','4','0');
lunbo('#sports2_slider','340','432','340','12','10','4','0');
lunbo('#sports3_slider','340','432','340','12','10','4','0');


// 户外运动选项卡
cards('#sport>.title>.card>a','#cloth>.sport','ah','sport_cur');
$('#sport>.title>.card>a').mouseenter(function () {
    $(this).addClass('ah').siblings().removeClass('ah');
    let index = $(this).index();
    $('#sport>.sport_con').eq(index).addClass('sport_cur').siblings('.sport_con').removeClass('sport_cur');
})


// 童装轮播
lunbo('#babycloths1_slider','340','432','340','12','10','4','0');
lunbo('#babycloths2_slider','340','432','340','12','10','4','0');
lunbo('#babycloths3_slider','340','432','340','12','10','4','0');

// 童装选项卡
cards('#babycloth>.title>.card>a','#babycloth>.babycloth_con','ah','babycloth_cur');

// 今日推荐选项卡
cards('#extend>.title>.radio>div','#extend>.extend_con','radio_cur','extend_con_cur');

// 回到顶部
$('#totop').click(function(){
    let step=100;
    let timer=setInterval(function(){         //每隔30毫秒向上滚动一次，利用定时器实现
        step+=50;    //加速度，每次都快50
        let st=document.documentElement.scrollTop || document.body.scrollTop;   //从新获取一次到顶部的距离
        let newSt=st-step;     //每30毫秒滚动的距离
        document.documentElement.scrollTop=newSt;
        document.body.scrollTop=newSt;     // 从新赋值，实现向上滚动
        if(newSt<=0){
            clearInterval(timer);
        }//判断距离是否为0，为0 就停止定时器，二次下滑时就不会再自动向上滚动
    },30)
})

// 顶部影藏搜索框
$(window).scroll(function(){
    let st=document.documentElement.scrollTop || document.body.scrollTop; 
    if(st>1000){
        $('#top_search').stop().fadeIn(300);
    }else{
        $('#top_search').stop().fadeOut(300);
    }
})

//右侧二维码
$('#right .er').hover(function(){
    $(this).find('img').eq(1).stop().animate({right:39},500);
},function(){
    $(this).find('img').eq(1).stop().animate({right:-70},500);
 
})
